package cn.edu.zzu.demo02Thread;

/**
 * 静态代理
 * 多线程中 Runnable就是静态代理实现的
 */
public class StaticProxy {

    public static void main(String[] args) {

        //线程
        new Thread(()->{
            System.out.println("静态代理");
        }).start();

        WeddingCompany weddingCompany = new WeddingCompany(new You());
        weddingCompany.happyMarry();
    }
}

interface Marry {
    void happyMarry();
}

class You implements Marry {
    @Override
    public void happyMarry() {
        System.out.println("我要结婚了！");
    }
}

class WeddingCompany implements Marry {

    private Marry marry;

    public WeddingCompany(Marry marry) {
        this.marry = marry;
    }

    @Override
    public void happyMarry() {

        //方法增强
        before();

        this.marry.happyMarry();

        after();
    }

    private void before() {
        System.out.println("布置场地！");
    }

    private void after() {
        System.out.println("收钱！");
    }
}